【Linux】Shell 从命令行提示自动输入,自动交互 您所在的位置:网站首页 linux 批处理 调用 执行程序 交互界面 输入数值 【Linux】Shell 从命令行提示自动输入,自动交互

【Linux】Shell 从命令行提示自动输入,自动交互

2024-07-10 21:07| 来源: 网络整理| 查看: 265

ssh自动化免密登陆,然而在大数据集群搭建过程中每个节点需要安装许多软件并且需要配置相关文件,所以现在我们实现一个自动安装软件脚本。

代码:(安装软件使用局域网yum源我之前写过:https://blog.csdn.net/a602519773/article/details/81909730)

这里我编写了两个shell脚本:ssh_copy和install.sh

脚本1:ssh_copy.sh

这个脚本中包含了两个方法,第一个是用于远程ssh操作,第二个是用来ssh每个节点;再下面的代码,首先使用expect实现交互式的执行auto_ssh(),然后在ssh_copy()中调用auto_ssh()实现多台主机免密,最后使用一个for循环将自动化安装脚本下发给各主机,并执行该脚本

#!/bin/bashservices="host02 host03"password=hadoopauto_ssh(){ expect -c "set timeout -1; spawn ssh-copy-id $1; expect { "*(yes/no)*" {send yes\r; exp_continue;} "*(password*)"{send $2\r;exp_continue;} eof {exit 0;} }"; }

ssh_copy(){ for service in $services do auto_ssh() $service $password done}ssh_copy

for service in $servicesdo scp -r install.sh root@$service:/root ssh root@$service /root/install.shdone 

脚本2:install.sh

#!/bin/bashbase_server=host01yum install -y wgetwget $base_server/soft/jdk-7u45-linux-x64.tar.gztar -zxvf jdk-7u45-linux-x64.tar.gz -C /usr/localcat >> /etc/profile > a.txt

[root@host01 soft]# cat a.txt

111

[root@host01 soft]# cat >> a.txt hello world

> EOF

[root@host01 soft]# cat a.txt

111

hello world

这里我们发现使用文本输入重定向,将输入的hello world追加到了a.txt文件中。

同理我们看上边代码,经过重定向我们将需要添加的配置信息:

export JAVA_HOME=/usr/local/jdk1.7.0_45export PATH=\$PATH:\$JAVA_HOME/bin

追加到了/etc/profile配置文件中。--------------------- 以上摘自:https://blog.csdn.net/a602519773/article/details/80637450

 

 

 

非交互式生成秘钥及实现批量管理

1、创建用户及密码(所有的机器都要执行)

useradd ydl

echo 123456|passwd --stdin ydl

id ydl

su - ydl

2、生成秘钥对

ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa>/dev/null 2>&1

3、分发秘钥

ssh-copy-id -i .ssh/id_dsa.pub [email protected]

 

单个自动分发秘钥:

[ydl@test-22 ~]$ cat fenfa_sshkey.exp

#!/usr/bin/expect

if { $argc != 2 } {

send_user "usage: expect fenfa_sshkey.exp file host\n"

exit

}

 

#define var

set file [lindex $argv 0]

set host [lindex $argv 1]

set password "123456"

#spawn scp /etc/hosts [email protected]:/etc/hosts

#spawn scp -P22 $file ydl@host:$dir

spawn ssh-copy-id -i $file "ydl@$host"

expect {

"yes/no" {send "yes\r";exp_continue}

"*password" {send "$password\r"}

}

expect eof

 

exit -onexit {

send_user "ydl say good bye to you!\n"

}

 

#script usage

#expect ydl-6.exp file host dir

#example

#expect fenfa_sshkey.exp file host dir

#expect fenfa_sshkey.exp ~/hosts 192.168.1.43:~

 

结果:expect fenfa_sshkey.exp .ssh/id_dsa.pub 192.168.1.186

 

 

批量分发脚本:

[ydl@test-22 ~]$ cat fenfa_sshkey.sh

#!/bin/sh

. /etc/init.d/functions

for ip in 43 186 192

do

expect fenfa_sshkey.exp ~/.ssh/id_dsa.pub 192.168.1.$ip >/dev/null 2>&1

if [ $? -eq 0 ];then

action "$ip" /bin/true

else

action "$ip" /bin/false

fi

done

 

一键自动化批量安装服务脚本

1.创建用户

useradd ydl123

echo 123456|passwd --stdin ydl123

id ydl123

2.sudo提权实现没有权限用户拷贝

配置sudoers

echo "ydl123 ALL= NOPASSWD:ALL ">>/etc/sudoers

visudo -c

su - ydl123

3.

脚本1、

[ydl123@test-22 ~]$ cat fenfa_sshkey.exp

#!/usr/bin/expect

if { $argc != 2 } {

send_user "usage: expect fenfa_sshkey.exp file host\n"

exit

}

 

#define var

set file [lindex $argv 0]

set host [lindex $argv 1]

set password "123456"

#spawn scp /etc/hosts [email protected]:/etc/hosts

#spawn scp -P22 $file ydl@host:$dir

spawn ssh-copy-id -i $file "ydl123@$host"

expect {

"yes/no" {send "yes\r";exp_continue}

"*password" {send "$password\r"}

 

}

expect eof

 

exit -onexit {

send_user "ydl say good bye to you!\n"

}

 

 

#script usage

#expect ydl-6.exp file host dir

#example

#expect fenfa_sshkey.exp file host dir

#expect fenfa_sshkey.exp ~/hosts 192.168.1.43:~

 

脚本2、

[ydl123@test-22 ~]$ cat auto_deploy.sh

#!/bin/sh

. /etc/init.d/functions

######################创建密钥#####################

ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa>/dev/null 2>&1

if [ $? -eq 0 ];then

action "create dsa $ip" /bin/true

else

action "create dsa $ip" /bin/false

exit 1

fi

#######################分发密钥###################

for ip in 43 186 192

do

expect fenfa_sshkey.exp ~/.ssh/id_dsa.pub 192.168.1.$ip >/dev/null 2>&1

if [ $? -eq 0 ];then

action "$ip" /bin/true

else

action "$ip" /bin/false

fi

done

######################dis fenfa scripts###########

for n in 43 186 192

do

scp -P 22 -rp ~/scripts [email protected].$n:~

done

###################install sevice################

for m in 43 186 192

do

ssh -t -p 22 [email protected].$m sudo /bin/bash ~/scripts/install.sh

done

验证成功!

 

 

---------------------

以上摘自:https://blog.csdn.net/yaodunlin/article/details/88127845

 

 

 

 

看看这个shell:https://www.cnblogs.com/YankaiJY/p/8832579.html

#!/bin/bash # Date: 4:42 2018-2-10 # Mail: [email protected] # Founder: # Describe: This is a one - button installation service script # 提示:使用此脚本时,尽量先选择第一项配置Yum源! red_col="\e[1;31m" reset_col="\e[0m" LOG_DIR=/usr/local/src . /etc/init.d/functions MMM=`rpm -qa | grep mariadb` #node 1. function caidan(){ cat /dev/null if [ "$?" -ne 0 ];then action "请您输入数值" /bin/false elif [[ "$NUM" == 0 ]];then action "请您输入比0大的数值" /bin/false fi } #node 3.Yum function Yum_check(){ echo -en "${red_col}正在配置Yum源,请稍等....\n${reset_col}" if [ -f /etc/yum.repos.d/CentOS-Base.repo ] then mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.back && \ wget http://mirrors.aliyun.com/repo/Centos-7.repo &>/dev/null && \ mv Centos-7.repo /etc/yum.repos.d/CentOS-Base.repo && yum clean all &>/dev/null && yum makecache &>/dev/null fi if [ "$?" -eq 0 ];then action "Yum源配置成功!!!" /bin/true else action "Yum源配置失败,请您检查网络" /bin/false exit 1 fi } #node 4.Nginx function Nginx_server(){ echo -en "${red_col}开始安装Nginx服务,请稍后.....\n${reset_col}" yum install gcc gcc-c++ pcre-devel zlib-devel openssl-devel -y &>/dev/null && useradd -M -s /sbin/nologin nginx && \ cd $LOG_DIR && wget http://nginx.org/download/nginx-1.12.2.tar.gz &>/dev/null && tar zxf nginx-1.12.2.tar.gz && \ cd $LOG_DIR/nginx-1.12.2 && ./configure --prefix=/usr/local/nginx --with-http_dav_module --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-http_ssl_module --with-http_gzip_static_module --user=nginx --group=nginx &>/dev/null && make &>/dev/null && make install &>/dev/null if [ -f /usr/local/nginx/sbin/nginx ] then ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin fi if [ "$?" -eq 0 ] then action "Nginx安装成功" /bin/true && /usr/local/nginx/sbin/nginx else action "Nginx安装失败,请检查" /bin/false exit 1 fi } #node 2. Apache function Apache_server(){ echo -en "${red_col}开始安装Apache服务,请稍后.....\n${reset_col}" yum install httpd -y &>/dev/null if [ "$?" -eq 0 ] then action "Apache安装成功!" /bin/true else action "Apache安装失败,请检查环境" /bin/false exit 1 fi } #node 3. MySQL function Mysql_server(){ echo -en "${red_col}开始安装Mysql数据库,请稍后.....\n${reset_col}" if [ -n $MMM ] then rpm -e mariadb-libs --nodeps 2&>/dev/null else action "mariadb卸载失败,请重试..." /bin/false exit 1 fi cd $LOG_DIR && { wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz &>/dev/null && tar zxf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz && \ mv mysql-5.7.18-linux-glibc2.5-x86_64 /usr/local/mysql && \ cd /usr/local/mysql/ && mkdir data && mkdir log && echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile && \ source /etc/profile && groupadd mysql && useradd -r -g mysql -s /bin/false mysql } cat /etc/my.cnf [client] socket=/usr/local/mysql/mysql.sock [mysqld] basedir=/usr/local/mysql datadir=/usr/local/mysql/data pid-file=/usr/local/mysql/data/mysqld.pid socket=/usr/local/mysql/mysql.sock log_error=/usr/local/mysql/log/mysql.err EOF if [ -f /etc/my.cnf ] then chmod 750 data/ && chown -R mysql . && chgrp -R mysql . && bin/mysqld --initialize --user=mysql && cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld && service mysqld start &> /dev/null else echo "MySQL安装失败!!!" exit 1 fi ln -s /usr/local/mysql/bin/mysql /usr/local/sbin ln -s /usr/local/mysql/bin/mysqladmin /usr/local/sbin #oo=`cat /usr/local/mysql/log/mysql.err | grep root@localhost | awk -F ":" '{print $4}' | cut -d " " -f 2` oo=`cat /usr/local/mysql/log/mysql.err | grep password | awk '{print $11}'` mysqladmin -uroot -p${oo} password pwd123 &>/dev/null if [ "$?" -eq 0 ] then action "MySQL数据库安装成功,密码为:pwd123" /bin/true else action "MySQL数据库安装失败密码初始化失败!" /bin/false fi } #node 4. PHP function php_server(){ echo -en "${red_col}开始安装依赖包,请稍后....\n${reset_col}" yum -y install libxml2-devel libcurl-devel openssl-devel bzip2-devel &> /dev/null if [ "$?" -eq 0 ];then action "依赖包安装完成" /bin/true else action "依赖包安装失败请检查环境!!!" /bin/false exit 1 fi yum -y install libxml2-devel libcurl-devel openssl-devel bzip2-devel libjpeg-devel libpng libpng-devel freetype-devel libmcrypt libmcrypt-devel &>/dev/null cd $LOG_DIR && { echo -en "${red_col}开始安装PHP请稍后,过程稍微有点长...\n${reset_col}" wget http://cn2.php.net/distributions/php-5.6.27.tar.gz &> /dev/null && \ tar zxf php-5.6.27.tar.gz && cd php-5.6.27/ && \ ./configure --prefix=/usr/local/php5.6 --with-config-file-path=/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/usr/local/mysql/mysql.sock --with-gd --with-iconv --with-libxml-dir=/usr --with-mhash --with-mcrypt-dir --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-zlib --with-freetype-dir --with-png-dir --with-jpeg-dir --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl &>/dev/null } if [ "$?" -eq 0 ] then make &>/dev/null && make install &>/dev/null else action "PHP安装失败,请检查环境..." /bin/false exit 1 fi echo -en "${red_col}正在配置PHP,请稍等....\n${reset_col}" cd /usr/local/src/php-5.6.27/ && { cp php.ini-production /etc/php.ini && cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm && chmod +x /etc/init.d/php-fpm && chkconfig --add php-fpm && chkconfig php-fpm on } if [ "$?" -eq 0 ];then cp /usr/local/php5.6/etc/php-fpm.conf.default /usr/local/php5.6/etc/php-fpm.conf && echo -en "${red_col}复制主配置成功${reset_col}" else action "配置PHP环境出错,请检查..." /bin/false exit 1 fi if [ ! -d /usr/local/php5.6/etc/php-fpm.conf ] then sed -i 's#;pid = run/php-fpm.pid#pid = run/php-fpm.pid#g' /usr/local/php5.6/etc/php-fpm.conf sed -i 's/listen = 127.0.0.1:9000/listen = 127.0.0.1:9000/g' /usr/local/php5.6/etc/php-fpm.conf sed -i 's/pm.max_children = 5/pm.max_children = 300/g' /usr/local/php5.6/etc/php-fpm.conf sed -i 's/pm.start_servers = 2/pm.start_servers = 20/g' /usr/local/php5.6/etc/php-fpm.conf sed -i 's/pm.min_spare_servers = 1/pm.min_spare_servers = 20/g' /usr/local/php5.6/etc/php-fpm.conf sed -i 's/pm.max_spare_servers = 3/pm.max_spare_servers = 100/g' /usr/local/php5.6/etc/php-fpm.conf sed -i 's/user = nobody/user = nginx/g' /usr/local/php5.6/etc/php-fpm.conf sed -i 's/group = nobody/group = nginx/g' /usr/local/php5.6/etc/php-fpm.conf else action "配置PHP环境出错,请检查..." /bin/false exit 1 fi if [ $? -eq 0 ] then systemctl start php-fpm && action "PHP启动成功" /bin/true else echo "启动PHP失败" exit 1 fi } #node 5. LNMP_server function LNMP(){ Nginx_server Mysql_server php_server echo -en "${red_col}开始安装LNMP环境,请稍后..可以喝杯茶~\n${reset_col}" if [ "$?" -eq 0 ];then echo -en "${red_col}LNMP安装完成,正在配置Nginx解析PHP请稍后....\n${reset_col}" else action "LNMP安装失败,请您检查环境..." /bin/false exit 1 fi if [ -f /usr/local/nginx/conf/nginx.conf ] then sed -i 's/index index.html index.htm;/index index.php index.html index.htm;/g' /usr/local/nginx/conf/nginx.conf sed -i 's/# root html;/ root html;/g' /usr/local/nginx/conf/nginx.conf sed -i 's/# fastcgi_pass 127.0.0.1:9000;/ fastcgi_pass 127.0.0.1:9000;/g' /usr/local/nginx/conf/nginx.conf sed -i 's/# fastcgi_index index.php;/ fastcgi_index index.php;/g' /usr/local/nginx/conf/nginx.conf sed -i 's*# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;* fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;*g' /usr/local/nginx/conf/nginx.conf sed -i 's/# include fastcgi_params;/ include fastcgi.conf;/g' /usr/local/nginx/conf/nginx.conf sed -i '71d' /usr/local/nginx/conf/nginx.conf && sed -i 'N;70a}' /usr/local/nginx/conf/nginx.conf sed -i '65d' /usr/local/nginx/conf/nginx.conf && sed -i 'N;64alocation ~ \\.php$ {' /usr/local/nginx/conf/nginx.conf else action "Nginx解析php失败,请您检查环境..." /bin/false exit 1 fi touch /usr/local/nginx/html/2018.php cat /usr/local/nginx/html/2018.php EOF /usr/local/nginx/sbin/nginx -s reload if [ "$?" -eq 0 ] then action "LNMP环境正式搭建成功,请您访问http://IP/2018.php" /bin/true else action "LNMP搭建失败啦,哈哈哈请您检查一下环境吧..." exit 1 fi } function zabbix_server(){ if [ -f /usr/local/nginx/sbin/nginx -a -f /etc/my.cnf -a -f /etc/php.ini ];then echo -en "${red_col}开始安装zabbix请稍后!!!\n${reset_col}" else action "提示:在安装zabbix之前请先安装LNMP环境!" /bin/false exit 1 fi groupadd zabbix && useradd -g zabbix zabbix sed -i 's/;date.timezone =/date.timezone = PRC/g' /etc/php.ini sed -i 's/expose_php = On/expose_php = Off/g' /etc/php.ini sed -i 's/short_open_tag = Off/short_open_tag = On/g' /etc/php.ini sed -i 's/post_max_size = 8M/post_max_size = 16M/g' /etc/php.ini sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /etc/php.ini sed -i 's/max_input_time = 60/max_input_time = 300/g' /etc/php.ini sed -i 's/;always_populate_raw_post_data = -1/always_populate_raw_post_data = -1/g' /etc/php.ini sed -i 's/;mbstring.func_overload = 0/mbstring.func_overload = 0/g' /etc/php.ini if [ "$?" -eq 0 ];then echo -en "${red_col}编辑/etc/php.ini文件成功!\n${reset_col}" else action "编辑/etc/php.ini文件失败!" /bin/false exit 1 fi yum install -y net-snmp net-snmp-devel curl-devel java-1.8.0-openjdk java-1.8.0-openjdk-devel OpenIPMI-devel libssh2-devel &>/dev/null if [ "$?" -eq 0 ] then action "zabbix依赖包安装成功!!!" /bin/true else action "zabbix依赖包安装失败" /bin/false exit 1 fi cd $LOG_DIR && { wget http://www.fping.org/dist/fping-3.10.tar.gz &>/dev/null && tar zxf fping-3.10.tar.gz &>/dev/null && \ cd fping-3.10/ && ./configure &>/dev/null && make &>/dev/null && make install &>/dev/null } if [ "$?" -eq 0 ] then chown root:zabbix /usr/local/sbin/fping && chmod 4710 /usr/local/sbin/fping else action "fping安装失败" /bin/false exit 1 fi cd $LOG_DIR && { wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.1/zabbix-3.2.1.tar.gz &>/dev/null && \ tar zxf zabbix-3.2.1.tar.gz && cd zabbix-3.2.1/ && \ ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-java --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-openipmi &>/dev/null && make &>/dev/null && make install &>/dev/null } if [ "$?" -eq 0 ] then action "zabbix安装成功,正在配置请稍后...." /bin/true else action "zabbix安装失败,请您检查环境...." /bin/false exit 1 fi ln -s /usr/local/zabbix/bin/* /usr/local/bin/ ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/ if [ "$?" -eq 0 ]; then /usr/local/sbin/mysql -uroot -ppwd123 -e 'create database zabbix character set utf8;' &>/dev/null /usr/local/sbin/mysql -uroot -ppwd123 -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'" &>/dev/null else action "zabbix创建软连接失败!" /bin/false exit 1 fi if [ "$?" -eq 0 ] then action "zabbix数据库创建成功!" /bin/true else action "zabbix数据库创建失败!" /bin/false exit 1 fi cd /usr/local/src/zabbix-3.2.1/database/mysql && { /usr/local/sbin/mysql -uzabbix -pzabbix -hlocalhost zabbix < schema.sql &>/dev/null /usr/local/sbin/mysql -uzabbix -pzabbix -hlocalhost zabbix < images.sql &>/dev/null /usr/local/sbin/mysql -uzabbix -pzabbix -hlocalhost zabbix < data.sql &>/dev/null } if [ "$?" -ne 0 ] then action "zabbix数据库导入失败!" /bin/false exit 1 else action "zabbix数据库导入成功!" /bin/true fi sed -i 's$LogFile=/tmp/zabbix_server.log$LogFile=/usr/local/zabbix/logs/zabbix_server.log$g' /usr/local/zabbix/etc/zabbix_server.conf sed -i 's$# PidFile=/tmp/zabbix_server.pid$PidFile=/usr/local/zabbix/logs/zabbix_server.pid$g' /usr/local/zabbix/etc/zabbix_server.conf sed -i 's/# DBHost=localhost/DBHost=localhost/g' /usr/local/zabbix/etc/zabbix_server.conf sed -i 's/# DBPassword=/DBPassword=zabbix/g' /usr/local/zabbix/etc/zabbix_server.conf sed -i 's/# DBPort=3306/DBPort=3306/g' /usr/local/zabbix/etc/zabbix_server.conf sed -i 's$# FpingLocation=/usr/sbin/fping$FpingLocation=/usr/sbin/fping$g' /usr/local/zabbix/etc/zabbix_server.conf sed -i 's$# DBSocket=/tmp/mysql.sock$DBSocket=/usr/local/mysql/mysql.sock$g' /usr/local/zabbix/etc/zabbix_server.conf mkdir -p /usr/local/zabbix/logs && chown -R zabbix:zabbix /usr/local/zabbix/ cat /dev/null if [ "$?" -eq 0 ];then action "zabbix主配修改成功,正在进行相关的配置~" /bin/true else action "zabbix发生了严重的错误!!!" /bin/false exit 1 fi cd /usr/local/src/zabbix-3.2.1/ && { cp misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server cp misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd chmod +x /etc/rc.d/init.d/zabbix_server chmod +x /etc/rc.d/init.d/zabbix_agentd chkconfig --add zabbix_server chkconfig --add zabbix_agentd chkconfig zabbix_server on chkconfig zabbix_agentd on } if [ "$?" -eq 0 ];then action "复制zabbix启动项成功" /bin/true else action "复制zabbix启动项失败!!" /bin/false exit 1 fi sed -i 's$BASEDIR=/usr/local$BASEDIR=/usr/local/zabbix/$g' /etc/rc.d/init.d/zabbix_server sed -i 's*PIDFILE=/tmp/$BINARY_NAME.pid*PIDFILE=/usr/local/zabbix/logs/$BINARY_NAME.pid*g' /etc/rc.d/init.d/zabbix_server sed -i 's$BASEDIR=/usr/local$BASEDIR=/usr/local/zabbix/$g' /etc/rc.d/init.d/zabbix_agentd sed -i 's*PIDFILE=/tmp/$BINARY_NAME.pid*PIDFILE=/usr/local/zabbix/logs/$BINARY_NAME.pid*g' /etc/rc.d/init.d/zabbix_agentd ldconfig && systemctl daemon-reload /etc/init.d/zabbix_agentd start &>/dev/null /etc/init.d/zabbix_server start &>/dev/null if [ "$?" -eq 0 ];then action "zabbix监控启动成功,正在进行配置页面,请稍后!!!" /bin/true else action "zabbix监控启动失败,请检查环境!!!" /bin/false exit 1 fi mkdir /usr/local/nginx/html/zabbix/ if [ -d /usr/local/nginx/html/zabbix/ ];then cp -r /usr/local/src/zabbix-3.2.1/frontends/php/* /usr/local/nginx/html/zabbix/ else action "zabbix目录创建失败" /bin/false exit 1 fi chown -R nginx:nginx /usr/local/nginx/html/zabbix if [ $? -eq 0 ];then echo "zabbix部署成功,请您访问http://IP/zabbix" else echo "zabbix部署失败,请检查环境!!!" exit 1 fi } function TC (){ echo -e "${red_col}此管理程序已经成功退出!\n${reset_col}" exit 0 } function GJ(){ echo -e "${red_col}即将关机,请稍后....\n${reset_col}" shutdown -h now } function zong(){ while : do panduan case $NUM in 1) Yum_check ;; 2) Nginx_server ;; 3) Apache_server ;; 4) Mysql_server ;; 5) php_server ;; 6) LNMP ;; 7) zabbix_server ;; 8) TC ;; 9) GJ ;; esac done } zong

 

待续

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有